<?

/*	Breadcrumb TEMPLATE
*	
*	renders a breadcrumb.
*
*	Paramaters: 	- Separator
*					- Element to place first inside breadcrumb element	
*	
*
*					*/
global $Page, $Engine;

$crumb = array();

$separator = $template_param;
if( func_num_args() > 2 ) $pre = func_get_arg(2);

$link = "";


$TreeEl = $Page;

while( $TreeEl ) {
	
	$crumb[] = ( $TreeEl->get( "name" ) == PAGE )?
		"<span class='active'>{$TreeEl->get( 'title' )}</span>" : "<a href='{$TreeEl->uri()}'>{$TreeEl->get( 'title' )}</a>";
	
	$TreeEl = ( $TreeEl->hasParent())? new PAGE(( int ) $TreeEl->get( "parent" )) : false;
	
}


if( $pre ) $crumb[] = "<a href='/?fresh=lang:" . LANG . "'>$pre</a>";
	
?>

<span id='breadcrumb'><?= implode( $separator, array_reverse( $crumb )) ?></span>